package com.yuyue.springFramework.note03.primitive;

import com.yuyue.springFramework.note03.service.IService;

/**
 * 原始代理类
 */
//实现目标类的接口
public class PrimitiveProxy implements IService {
    //获取目标类
    private final IService target;

    public PrimitiveProxy(IService target){
        this.target = target;
    }

    //逐个实现目标类的代理逻辑
    @Override
    public void fun1() {
        long startTime = System.nanoTime();
        target.fun1();
        long endTime = System.nanoTime();
        System.out.println(this.target.getClass().getSimpleName() + "执行fun1，耗时（纳秒）"+ (endTime - startTime));
    }

    @Override
    public void fun2() {
        long startTime = System.nanoTime();
        target.fun2();
        long endTime = System.nanoTime();
        System.out.println(this.target.getClass().getSimpleName() + "执行fun2，耗时（纳秒）"+ (endTime - startTime));
    }

    @Override
    public void fun3() {
        long startTime = System.nanoTime();
        target.fun3();
        long endTime = System.nanoTime();
        System.out.println(this.target.getClass().getSimpleName() + "执行fun3，耗时（纳秒）"+ (endTime - startTime));
    }
}
